Imports KanBan.Pgd.Common
Imports KanBan.Pgd.Domain.Entities
Imports NUnit.Framework
Imports KanBan.Pgd.DataBase.Resources
Imports KanBan.Pgd.Infrastructure.Repositories

<TestFixture()> _
Public Class BulkDataPopulationTest
    Inherits BaseDataPopulationTest

    Protected Overrides Sub PopulateProfiles()

        Dim profileRepository As New ProfileRepository()

        Dim resource As ProfileResource = ProfileResource.GetResource()

        Dim area As Area
        Dim ar As New AreaRepository()

        For Each p As ProfileItem In resource.Profiles

            area = ar.GetById(New Guid(p.AreaId))

            profileRepository.SaveOrUpdate(New Profile(New Guid(p.Id), p.Name, area))
        Next

    End Sub

    Protected Overrides Sub PopulateAreas()

        Dim ar As New AreaRepository()

        Dim resource As AreaResource = AreaResource.GetResource()

        For Each ai As AreaItem In resource.Areas()
            ar.SaveOrUpdate(New Area(New Guid(ai.Id), ai.Name))
        Next

    End Sub

    Protected Overrides Sub PopulateUsers()

        Dim ur As New UserRepository()
        Dim pr As New ProfileRepository()

        Dim resource As UserResource = UserResource.GetResource()

        For Each ui As UserItem In resource.Users
            ur.SaveOrUpdate(New User(New Guid(ui.Id), _
                                     ui.Name, _
                                     ui.UserName, _
                                     ui.Password, _
                                     pr.GetById(New Guid(ui.ProfileId))))
        Next

    End Sub

    Protected Overrides Sub LoadUsersToGroups()

        Dim ur As New UserRepository()
        Dim gr As New GroupRepository()

        Dim resource As UserResource = UserResource.GetResource()


        Dim group As Group
        Dim user As User
        For Each ui As UserItem In resource.Users

            group = gr.GetById(New Guid(ui.GroupId))
            user = ur.GetById(New Guid(ui.Id))
            gr.AddUser(group, user)

        Next

    End Sub

    Protected Overrides Sub PopulateGoals()

        Dim gdr As New GoalDefinitionRepository()
        Dim ar As New AreaRepository()
        Dim pr As New ProfileRepository()

        Dim resource As GoalDefinitionResource = GoalDefinitionResource.GetResource

        Dim goalDefinition As GoalDefinition
        Dim area As Area
        Dim profile As Profile
        For Each gdi As GoalDefinitionItem In resource.GoalDefinitions

            area = ar.GetById(New Guid(gdi.AreaId))
            profile = pr.GetById(New Guid(gdi.ProfileId))

            goalDefinition = New GoalDefinition(New Guid(gdi.Id), _
                                                gdi.Name, _
                                                area, _
                                                profile)

            goalDefinition.Description = gdi.Description

            gdr.SaveOrUpdate(goalDefinition)

        Next

    End Sub

    Protected Overrides Sub PopulateCompetencies()

        Dim cr As New CompetencyRepository()
        Dim ar As New AreaRepository()

        Dim resource As CompetencyResource = CompetencyResource.GetResource

        Dim area As Area
        Dim competency As Competency
        For Each ci As CompetencyItem In resource.Competnecies

            area = ar.GetById(New Guid(ci.AreaId))

            competency = New Competency(New Guid(ci.Id), ci.Name, area)

            competency.Description = ci.Description

            cr.SaveOrUpdate(competency)

        Next

    End Sub

    Protected Overrides Sub PopulateCandidates()
        MyBase.PopulateCandidates()
    End Sub

    Protected Overrides Sub PopulateRooms()
        MyBase.PopulateRooms()
    End Sub

    Protected Overrides Sub PopulateUserCompetencies()

    End Sub

    Protected Overrides Sub PopulateSearchRequests()

    End Sub

    Protected Overrides Sub PopulateSearchRequestCandidates()

    End Sub

    Protected Overrides Sub PopulateInterviews()

    End Sub

    Protected Overrides Sub PopulatePerformanceEvaluations()

    End Sub

End Class
